package cn.itcast.web.controller.cargo;

import cn.itcast.domain.cargo.Packing;
import cn.itcast.domain.cargo.PackingExample;
import cn.itcast.service.cargo.PackingService;
import cn.itcast.web.controller.BaseController;
import com.alibaba.dubbo.config.annotation.Reference;
import com.github.pagehelper.PageInfo;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;

@Controller
@RequestMapping("cargo/packing")
public class PackingController extends BaseController {

	@Reference
	PackingService packingService;

	@RequestMapping(value = "list",name = "装货单列表")
	public String findAll(
		@RequestParam(defaultValue = "1")int page,
		@RequestParam(defaultValue = "10")int size){

		//设置条件
		PackingExample packingExample = new PackingExample();
		PackingExample.Criteria criteria = packingExample.createCriteria();
		criteria.andExportIdEqualTo(getCompanyId());

		packingExample.setOrderByClause("input_date desc");

		PageInfo pageInfo = packingService.findAll(page, size,packingExample);
		request.setAttribute("page",pageInfo);


		return "cargo/packing/packing-list";
	}

	@RequestMapping(value = "edit",name="新增装货单")
	public String edit(Packing packing){

		packingService.save(packing);


		return "redirect:/cargo/packing/list.do";
	}



	@RequestMapping(value = "delete",name = "删除装货单")
	public String deletById(String id){
		packingService.deletById(id);
		return "redirect:/cargo/packing/list.do";
	}


}
